import tkinter as tk
# 建立窗口
window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
#创建一个Frame组建
frm1 = tk.Frame(window,relief='groove',bd=1,padx=60,pady=30)
frm1.pack()
tk.Label(frm1,text="这里是frm1").pack()

window.mainloop()



import tkinter as tk
 
root = tk.Tk()
label_left = tk.Label(root, text="Left")
label_right = tk.Label(root, text="Right")
 
# 将两个标签放在根窗口中并设置为左右布局
label_left.pack(side=tk.LEFT)
label_right.pack(side=tk.RIGHT)
 
root.mainloop()


import tkinter as tk
 
root = tk.Tk()
label_top = tk.Label(root, text="Top")
label_bottom = tk.Label(root, text="Bottom")
 
# 将两个标签放在根窗口中并设置为上下布局
label_top.grid(row=0, columnspan=2)
label_bottom.grid(row=1, columnspan=2)
 
root.mainloop()



import tkinter as tk
 
root = tk.Tk()
label_center = tk.Label(root, text="Center")
button_left = tk.Button(root, text="Left")
button_right = tk.Button(root, text="Right")
 
# 将三个部件放在根窗口中并设置其相对位置
label_center.place(relx=.5, rely=.5, anchor='c') # 居中显示
button_left.place(relx=0, rely=0.8, anchor='nw') # 靠近左上角
button_right.place(relx=1, rely=0.8, anchor='ne') # 靠近右上角
 
root.mainloop()